package org.odst.transformer;

import org.odst.controller.SheetTransformationController;
import org.odst.parser.Cell;
import org.odst.tag.Block;
import org.odst.tag.Tag;
import org.odst.transformation.ResultTransformation;

/**
 * Implementation of {@link RowTransformer} for transforming jx tags
 * @author Leonid Vysochyn
 * @author Cyril PODER
 */
public class TagRowTransformer extends BaseRowTransformer {

    Cell cell;
    Tag tag;

    private ResultTransformation resultTransformation;

    public TagRowTransformer(Row row, Cell cell) {
        this.cell = cell;
        this.row = row;
        this.tag = cell.getTag();
    }

    public ResultTransformation getTransformationResult() {
        return resultTransformation;
    }

    public ResultTransformation transform(SheetTransformationController stc, SheetTransformer sheetTransformer/*, ResultTransformation previousTransformation*/) {
        tag.getTagContext().setSheetTransformationController( stc );
        resultTransformation = tag.process( sheetTransformer );
        return resultTransformation;
    }

    public Block getTransformationBlock() {
        return tag.getTagContext().getTagBody();
    }

    public void setTransformationBlock(Block block) {
        tag.getTagContext().setTagBody( block );
    }

}
